package com.webchat.Utils;

import java.util.Random;

/**
 * Created by YongX on 2016/8/22.
 */
public class RandomStringUtil {
    private static final String skey = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789";
    private static final String ikey = "0123456789";

    public static final String getRandomString(int max){
        int length = skey.length();
        Random rand = new Random();
        StringBuffer key = new StringBuffer();
        for (int i = 0; i < max; i++){
            key.append(skey.charAt(rand.nextInt(length-1)));
        }
        return key.toString();
    }

    public static final String getRandomInteger(int max){
        int length = ikey.length();
        StringBuffer key = new StringBuffer();
        Random rand = new Random();
        for (int i = 0; i < max; i++){
            key.append(ikey.charAt(rand.nextInt(length-1)));
        }
        return key.toString();
    }
}
